import {
  ComponentCtor,
  ActionDescriptor,
  isString,
  capitalize,
  getWidget,
  getBehaviorByKey,
} from '../../vendors/handie';

function getActionComponent({ widget, renderType }: ActionDescriptor): ComponentCtor | undefined {
  if (widget) {
    return isString(widget) ? getWidget(widget as string) : (widget as ComponentCtor);
  }

  return getWidget(
    `${capitalize(renderType || getBehaviorByKey('common.action.renderType') || '')}ActionWidget`,
  );
}

export { getActionComponent };
